# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=zangband
pkgver=2.7.5.1
_pkgver=2.7.5pre1
pkgrel=2
pkgdesc="Roguelike computer role playing game based on Angband"
url="https://sourceforge.net/projects/zangband/"
license="custom"
arch="all"
makedepends="automake autoconf util-linux ncurses-dev"
depends="ncurses"
source="https://downloads.sourceforge.net/zangband/zangband-$_pkgver.tar.gz
	fix-bad-substitution.patch
	fix-bad-configure.patch
	fix-random-num-gen.patch
	fix-explosive-rune-error.patch
	fix-spear-of-hagen-error.patch"
builddir="$srcdir/zangband"
options="!check"

prepare() {
	default_prepare
	autoreconf -vfi

	sed -i 's@# define DEFAULT_PATH "./lib/"@# define DEFAULT_PATH "/usr/lib/zangband/"@' $builddir/src/z-config.h
	sed -i 's@strcpy(path, "./lib/");@strcpy(path, "/usr/lib/zangband/");@' $builddir/src/main.c
}

build() {
	./configure --prefix=/usr/lib --with-gtk=no
	make
}

package() {
	install -d "$pkgdir"/usr/lib/zangband
	install -D -m755 zangband "$pkgdir"/usr/bin/zangband
	cp -R "$srcdir"/zangband/lib "$pkgdir"/usr/lib
	rename "$pkgdir"/usr/lib/lib "$pkgdir"/usr/lib/zangband "$pkgdir"/usr/lib/lib
	chmod -R 775 "$pkgdir"/usr/lib/zangband
	chown -R root:users "$pkgdir"/usr/lib/zangband

	find "$pkgdir"/usr/lib/zangband -name makefile.zb -exec rm {} \;
	find "$pkgdir"/usr/lib/zangband -type f -exec chmod a-x {} \;
}

sha512sums="3eb0dc460c98278cceb06fedaec9e844418a92d791baccafcd3c6591cfb7021dc15188a52b4a5d951c23f55444650ed1b7005b49c3ac1773a19657f4ea1ac512  zangband-2.7.5pre1.tar.gz
ad764771aecc5421a3f25f01b15fe72cf44b17f5a58915ef1f44d2f3d9d8c19f22efffcfc37513deb587f88f6c7ed3f3da82942a922d74ebb307213a3ad3e90b  fix-bad-substitution.patch
e0551b511c8b6c716704e2799f695f6314246a7c083f1f2ee23761a1d3227d4073e97f4af47e75daef271798b4b65d717a65cb56bae19eb45913321fd906c829  fix-bad-configure.patch
937627adfe6897c6195e28015de2fe6b796f402147f45a76b39c1bb4c0ba5e4e6c65d9153bc500ec481f3b0a92c048043efd9fbfe1300dfb9f3e57974e0c3d06  fix-random-num-gen.patch
2313da3a678212771cb5f51918bf7f1966e941b346d02538c5f13fdb0b43f208028cd61f50bb161180df1b2f3b496045c712fc39f4945c8ee029258faf6c7310  fix-explosive-rune-error.patch
6e5193a15a5fbb3947cb07363b15761c89405e050bcc13196c5106177843351df2d1ed3c06b95de1c6ecde4f3f614ef102a944270b500c2494d875de0adca8c3  fix-spear-of-hagen-error.patch"
